var chunk = function (arr, size) {
    if (arr.length === 0) {
        return []
    }
    let result = []
    let init = arr
    while (init.length > size) {
        let temp = []
        for (let i = 0; i < size; i++) {
            temp.push(arr.shift())
        }
        result.push(temp)
    }
    result.push(init)
    return result
}

chunk([1, 2, 3, 4, 5], 1)